<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // a在前为降序，b在前为升序
        var list = [
            {name:"小妹", datetime: "2021-07-09"},
            {name:"小妹", datetime: "2021-03-09"},
            {name:"小妹", datetime: "2021-09-09"}
        ]
        list.sort((a, b) => {
            return new Date(b.datetime).getTime() - new Date(a.datetime).getTime()
        });

        // < 为降序； > 为升序
        // list.sort(function(a,b){
        // 　　return a.datetime < b.datetime ? 1 : -1
        // })
        console.log(list)

    </script>
</body>
</html>